package com.example.news_demo.service;

import com.example.news_demo.entity.User;
import com.example.news_demo.entity.ViewLog;
import com.example.news_demo.mapper.UserMapper;
import com.example.news_demo.mapper.ViewLogMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User getOne(String username){
        return userMapper.getOne(username);
    }

    public List<User> getAll(){
        return userMapper.getAll();
    }

    public void insertUser(User user){
        userMapper.insertUser(user);
    }

    public void deleteUser(String username,String pwd){
        userMapper.deleteUser(username,pwd);
    }

    public boolean checkLogin(String username,String pwd){
        User user = userMapper.getOne(username);
        if(pwd.equals(user.getPwd())){
            return true;
        }
        return false;
    }
    public User getOneById(int n){
        return userMapper.getOneById(n);
    }
}
